<?php
class Modelradio_freq extends ModelBase {
	
	//protected $tablename = 'null';
	
	protected $baseurl = 'http://playbill.qingting.fm/api/vehicle/';
	protected $kid = 1086;
	protected $key = '625c2609f9e5fbcdefadcdb296b60d00';
	protected $tablename = 'tbl_radio_freq';
	
	
	
	/**
	 *
	 * @var CDbConnection
	 */
	function __construct() {
		parent::__construct ('ienjoy');
	}
	
	
	//获取蜻蜓数据
	/**
	 * 获取国际电台，在电台信息请求中增加rid参数。
	&rid=1表示国际电台
	rid表示电台的类型，0表示国内电台，默认值，1表示国际电台。
	 * @return mixed
	 */
	function getBaseContent($isjson=0) {
		$qtcontent = get_url_content($this->baseurl.'/getchannelsV2?id='.$this->kid.'&key='.$this->key.'&nocache=1');
		
		if($isjson){
			return $qtcontent;
		}else{
			$decodeJson = json_decode($qtcontent,true);
			
			if(isset($decodeJson['channels'])){
				return $decodeJson['channels'];
			}else{
				return null;
			}
			return $decodeJson;
		}
	}
	//通过channelID获取节目单
	function getPlaybill($isjson=0){
		$playbillcontent = get_url_content($this->baseurl.'/getchannelprograms?id='.$this->kid.'&key='.$this->key.'&nocache=1&channelid='.$id);
		
		if($isjson){
			return $playbillcontent;
		}else{
			$decodeJson = json_decode($playbillcontent,true);
			if(isset($decodeJson['days'])){
			    return $decodeJson['days'];
			}else{
				return null;
			}
		}
	}
	
	// 加或修改路书
	function replaceTable($updatear) {
		$updatear ['data'] ['update_time'] = time ();
		return parent::replaceTable ( $this->tablename, $updatear ['data'] );
	}
	
	// 到路书列表
	function getTable($where) {
		$arr = parent::getTable ( $this->tablename, $where );
		return $arr;
	}
	
	
	
}
?>
